package stream;

import pojo.UserInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Map相当于条件筛选,本案例筛选出了name列表
 */
public class Map {
    public static void main(String[] args) {
        ArrayList<UserInfo> list = new ArrayList();
        list.add(new UserInfo(1, "张三", 1));
        list.add(new UserInfo(2, "李四", 2));
        list.add(new UserInfo(3, "王五", 3));
        list.add(new UserInfo(3, "赵六", 4));
        List<String> collect = list.stream()
                .distinct()
                .map(UserInfo::getName)
                .collect(Collectors.toList());
        System.out.println(collect);
    }
}
